function sendSms(){
	var mobile = $('#mobile_phone').val();
	var flag = $('#flag').val();
	var code = $("#sms_code").val();
	var h_code = $("#h_code").val();
	if(mobile.length == ''){
		alert('请填写手机号码');
		return false;
	}
	var ret;
$.ajax({
url : "index.php?m=default&c=sms&a=send&flag="+flag,
data:{ "mobile": mobile, "sms_code": code,"h_code":h_code},
cache : false,
async : false,
type : "POST",
dataType : 'json',
success : function (result){
		if (result.code==2){
			RemainTime();
			if(result.msg)
			alert(result.msg);
			else
			alert('手机验证码已经成功发送到您的手机');
			ret= true;
			step++;
		}else{
			if(result.msg){
				alert(result.msg);
				ret=  false;
			}else{
				alert('手机验证码发送失败');
				ret=  false;
			}
		}
}
}); 

return ret;
}

function register2(){
	var status = true;
	var mobile = $('#mobile_phone').val();
	var mobile_code = $('#mobile_code').val();
	var password = $('#password').val();
	
	if(step==0)
	{
	if(mobile.length == ''){
		alert('请填写手机号码');
		return false;
	}
		if(password.length == ''){
		alert('请输入密码');
		return false;
	}
	if(password.length <6){
		alert('密码长度过短');
		return false;
	}
		if(password.length >=15){
		alert('密码长度过长');
		return false;
	}
	var re = /^1[3|5][0-9]\d{4,8}$/;
	if (re.test(setInterval(mobile))) {
        alert("手机格式不正确");
        return false;
    }
   return  sendSms();
/*	$.ajax({
		type: "POST",
		url: "index.php?m=default&c=sms&a=checkmobile",
		data: "mobile="+mobile,
		dataType: "json",
		async: false,
		success: function(result){
			if (result.code!=2){
				alert(result.msg);
				status = false;
				return false;
			}
			return status;
		}
	});*/

	}
	if(step==1)
	{
	if(mobile_code.length == ''){
		alert('请填写手机验证码');
		return false;
	}
	$('#submit').show();
}
	
		if(step==2)
		{
				
				
		}
		step++;
		return true;
}

function submitForget(){
	var status = true;
	var mobile = $('#mobile_phone').val();
    var mobile_code = $('#mobile_code').val();
	if(mobile.length == ''){
		alert('请填写手机号码');
		return false;
	}
	if(mobile_code.length == ''){
		alert('请填写手机验证码');
		return false;
	}
	$.ajax({
		type: "POST",
		url: "index.php?m=default&c=sms&a=check",
		data: "mobile="+mobile+"&mobile_code="+mobile_code,
		dataType: "json",
		async: false,
		success: function(result){
			if (result.code!=2){
				alert(result.msg);
				status = false;
			}
		}
	});
	return status;
}
		
var iTime = 59;
var Account;
function RemainTime(){
/*  document.getElementById('zphone').disabled = true;*/

  var iSecond,sSecond="",sTime="";
  if (iTime >= 0){
    iSecond = parseInt(iTime%60);
    if (iSecond >= 0){
      sSecond = iSecond + "秒";
    }
    sTime=sSecond;
    if(iTime==0){
      clearTimeout(Account);
      sTime='获取手机验证码';
      iTime = 59;
     /* document.getElementById('zphone').disabled = false;*/
    }else{
      Account = setTimeout("RemainTime()",1000);
      iTime=iTime-1;
    }
  }else{
    sTime='没有倒计时';
  }
 $('#zphone').text(sTime);
}
